package com.jltx.xq.relaxnewspro.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.jltx.xq.relaxnewspro.R;
import com.jltx.xq.relaxnewspro.utils.ViewHelper;

/**
 * Created by bo on 2017/4/9.
 */

public abstract class AbsTopNavigationFragment extends Fragment{
    protected View parentView;
    protected ViewPager viewPager;
    protected TabLayout tabLayout;
    protected PagerAdapter pagerAdapter;
    protected abstract PagerAdapter initPagerAdapter();
    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        parentView = inflater.inflate(R.layout.layout_top_navigation,container,false);
        viewPager = ViewHelper.findViewById(parentView,R.id.inner_viewpager);
        tabLayout = ViewHelper.findViewById(getActivity(),R.id.tab_layout);
        tabLayout.setVisibility(View.VISIBLE);
        pagerAdapter = initPagerAdapter();
        viewPager.setAdapter(pagerAdapter);
        tabLayout.setupWithViewPager(viewPager);
        return parentView;
    }
}
